| Conditions | 1 |
| Paths | 1 |
| Total Lines | 57 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | /*jshint node:true */ |
||
| 2 | module.exports = function ( grunt ) { |
||
| 3 | |||
| 4 | 'use strict'; |
||
| 5 | |||
| 6 | grunt.loadNpmTasks( 'grunt-contrib-jshint' ); |
||
| 7 | grunt.loadNpmTasks( 'grunt-jsonlint' ); |
||
| 8 | grunt.loadNpmTasks( 'grunt-banana-checker' ); |
||
| 9 | |||
| 10 | grunt.initConfig( { |
||
| 11 | jshint: { |
||
| 12 | options: { |
||
| 13 | // Enforcing |
||
| 14 | "bitwise": true, |
||
| 15 | "curly": true, |
||
| 16 | "eqeqeq": true, |
||
| 17 | "freeze": true, |
||
| 18 | "latedef": "nofunc", |
||
| 19 | "noarg": true, |
||
| 20 | "nonew": true, |
||
| 21 | "undef": true, |
||
| 22 | "unused": true, |
||
| 23 | "strict": true, |
||
| 24 | |||
| 25 | // ECMAScript version |
||
| 26 | "esversion": 3, |
||
| 27 | |||
| 28 | // Environment |
||
| 29 | "browser": true, |
||
| 30 | "jquery": true, |
||
| 31 | |||
| 32 | // map of global variables, with keys as names and a boolean value to determine if they are assignable |
||
| 33 | "globals": { |
||
| 34 | "mediaWiki": false |
||
| 35 | }, |
||
| 36 | |||
| 37 | "ignores": [] |
||
| 38 | }, |
||
| 39 | all: [ |
||
| 40 | '**/*.js', |
||
| 41 | '!node_modules/**' |
||
| 42 | ] |
||
| 43 | }, |
||
| 44 | banana: { |
||
| 45 | all: 'i18n/' |
||
| 46 | }, |
||
| 47 | jsonlint: { |
||
| 48 | all: [ |
||
| 49 | '**/*.json', |
||
| 50 | '!node_modules/**' |
||
| 51 | ] |
||
| 52 | } |
||
| 53 | } ); |
||
| 54 | |||
| 55 | grunt.registerTask( 'lint', [ 'jshint', 'jsonlint', 'banana' ] ); |
||
| 56 | grunt.registerTask( 'test', [ 'lint' ] ); |
||
| 57 | grunt.registerTask( 'default', 'test' ); |
||
| 58 | }; |
||
| 59 |